﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapper;
using System.Data;
using Demo.Net.Dapper;
using Npgsql; // 引入 Npgsql 命名空间

namespace Microsoft.Extensions.DependencyInjection
{
    public static class DapperDBComExtensions
    {

        public static IServiceCollection AddDapperExtensions(this IServiceCollection services, IConfiguration configuration)
        {
            services.AddScoped<IDbConnection>(sp => new NpgsqlConnection(configuration["PgSqlConnectionString"]));

            //注入Dapper相关
            services.AddTransient<DapperDbCom>();
            return services;
            
        }
    }
}
